package s_000_util;

import lombok.Getter;
import lombok.Setter;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class IOCBeanUtil {

    @Getter
    @Setter
    private AnnotationConfigApplicationContext applicationContext;

    public IOCBeanUtil(Class<?> annotatedClasses) {
        this.applicationContext = new AnnotationConfigApplicationContext(annotatedClasses);
        printBeans();
    }

    private void printBeans() {
        System.out.println("============容器中的对象==========");
        String[] definitionNames = applicationContext.getBeanDefinitionNames();
        for (String name : definitionNames) {
            System.out.println(name);
        }
        System.out.println("=================================");
    }
}
